import { useEffect } from "@/framework/vue/hooks";

/**
 * IPC事件监听钩子函数
 * @param event
 * @param listener
 */
export function useIpcListener(event: string, listener: (...args: any[]) => void) {
  if (!window.native?.ipc) return;

  useEffect(() => {
    const eventId = native.ipc.on(event, listener);
    return () => {
      native.ipc.off(event, eventId);
    };
  });
}
